package com.dtx.csnotes.stack;

import java.util.Iterator;

public class LinkedListStackDemo {

    public static void main(String[] args) throws Exception {
        MyStack<String> linkedListStack = new LinkedListStack<>();
        linkedListStack.push("A");
        linkedListStack.push("B");
        linkedListStack.push("C");
        linkedListStack.push("D");
        linkedListStack.push("E");
        System.out.println(linkedListStack.size());
        Iterator<String> iterator = linkedListStack.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
        System.out.println(linkedListStack.pop());
        System.out.println(linkedListStack.pop());
        System.out.println(linkedListStack.pop());
        System.out.println(linkedListStack.pop());
        System.out.println(linkedListStack.pop());
        try {
            System.out.println(linkedListStack.pop());
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println(linkedListStack.size());
    }
}
